package com.candy.candysocket.business.controller;

import com.candy.candycommon.utils.ResultBean;
import com.candy.candysocket.mq.ProducerExampleBoot;
import com.candy.candysocket.mq.TopicUtils;
import lombok.AllArgsConstructor;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * @author suYanLong
 * @version 1.0
 * @date 2023/3/16 14:47
 * @Description 消息发送
 * http://localhost:8080/socket/sendMsg?msg=测试
 * ws://localhost:8080/websocket/notice/1
 */
@AllArgsConstructor
@RestController
@RequestMapping("/socket")
public class SocketController {

    private final ProducerExampleBoot producerExampleBoot;

    @GetMapping("/sendMsg")
    public ResultBean sendMsg(String msg) {
//        NoticeWebsocket.sendMessage("你好，WebSocket");
        producerExampleBoot.sendMsg(TopicUtils.myGroup, msg);
        return ResultBean.ok();
    }

}
